﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotJog.Controls.RowDefinitionEx
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Windows;
using System.Windows.Controls;


namespace DnProcessSimulateCommands.RobotJog.Controls;

public static class RowDefinitionEx
{
  public static double _pixels;

  public static void Collapse(this RowDefinition row, bool bCollapse)
  {
    if (!(row.Parent is Grid parent))
      return;
    GridLength height = row.Height;
    GridUnitType gridUnitType = height.GridUnitType;
    height = row.Height;
    double pixels = height.Value;
    Visibility visibility;
    GridUnitType type;
    if (bCollapse)
    {
      visibility = Visibility.Collapsed;
      height = row.Height;
      if (height.IsAbsolute)
      {
        height = row.Height;
        RowDefinitionEx._pixels = height.Value;
        RowDefinition rowDefinition = row;
        height = row.Height;
        // ISSUE: variable of a boxed type
        __Boxed<double> local = (ValueType) height.Value;
        rowDefinition.Tag = (object) local;
      }
      type = GridUnitType.Auto;
    }
    else
    {
      visibility = Visibility.Visible;
      if (RowDefinitionEx._pixels != 0.0)
        pixels = RowDefinitionEx._pixels;
      type = GridUnitType.Pixel;
    }
    row.Height = new GridLength(pixels, type);
    int row1 = row.Index();
    for (int col = 0; col < parent.ColumnDefinitions.Count; ++col)
    {
      UIElement child = parent.GetChild(row1, col, typeof (UIElement));
      if (child != null && child.Visibility != visibility)
        child.Visibility = visibility;
    }
  }

  public static bool IsCollapsed(this RowDefinition row)
  {
    Grid parent = row.Parent as Grid;
    int row1 = row.Index();
    for (int col = 0; col < parent.ColumnDefinitions.Count; ++col)
    {
      UIElement child = parent.GetChild(row1, col, typeof (UIElement));
      if (child != null && child.Visibility == Visibility.Visible)
        return false;
    }
    return true;
  }

  public static int Index(this RowDefinition row)
  {
    int num = 0;
    if (row.Parent is Grid parent)
      num = parent.RowDefinitions.IndexOf(row);
    return num;
  }
}
